package com.j2eefast.flowable.bpm.service;


import com.j2eefast.flowable.bpm.entity.bpmCrmSubstitutionEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmSubstitutionMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 置换信息表Service接口
 * @author: yhli
 * @date 2020-06-27 20:13
 */
@Service
public class bpmCrmSubstitutionService extends ServiceImpl<bpmCrmSubstitutionMapper,bpmCrmSubstitutionEntity> {

	@Resource
	private bpmCrmSubstitutionMapper bpmCrmSubstitutionMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmSubstitutionEntity> queryWrapper = new QueryWrapper<bpmCrmSubstitutionEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String inCarVin = (String) params.get("inCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(inCarVin), "in_car_vin", inCarVin);
          String inCarVehicle = (String) params.get("inCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(inCarVehicle), "in_car_vehicle", inCarVehicle);
          String inCarMileage = (String) params.get("inCarMileage");
         queryWrapper.eq(ToolUtil.isNotEmpty(inCarMileage), "in_car_mileage", inCarMileage);
          String inCarAskprice = (String) params.get("inCarAskprice");
         queryWrapper.eq(ToolUtil.isNotEmpty(inCarAskprice), "in_car_askprice", inCarAskprice);
                String purchaseIsbuy = (String) params.get("purchaseIsbuy");
         queryWrapper.eq(ToolUtil.isNotEmpty(purchaseIsbuy), "purchase_isbuy", purchaseIsbuy);
          String purchaseEvaluation = (String) params.get("purchaseEvaluation");
         queryWrapper.eq(ToolUtil.isNotEmpty(purchaseEvaluation), "purchase_evaluation", purchaseEvaluation);
          String warehouseInCheck = (String) params.get("warehouseInCheck");
         queryWrapper.eq(ToolUtil.isNotEmpty(warehouseInCheck), "warehouse_in_check", warehouseInCheck);
          String warehouseInEvaluation = (String) params.get("warehouseInEvaluation");
         queryWrapper.eq(ToolUtil.isNotEmpty(warehouseInEvaluation), "warehouse_in_evaluation", warehouseInEvaluation);
                   String filehumanInRemark = (String) params.get("filehumanInRemark");
         queryWrapper.eq(ToolUtil.isNotEmpty(filehumanInRemark), "filehuman_in_remark", filehumanInRemark);
          String checkmoneyCashierReview = (String) params.get("checkmoneyCashierReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(checkmoneyCashierReview), "checkmoney_cashier_review", checkmoneyCashierReview);
          String checkmoneyProofpath = (String) params.get("checkmoneyProofpath");
         queryWrapper.eq(ToolUtil.isNotEmpty(checkmoneyProofpath), "checkmoney_proofpath", checkmoneyProofpath);
          String checkmoneyLoanamountreceived = (String) params.get("checkmoneyLoanamountreceived");
         queryWrapper.eq(ToolUtil.isNotEmpty(checkmoneyLoanamountreceived), "checkmoney_loanamountreceived", checkmoneyLoanamountreceived);
          String checkmoneyReceiptnumber = (String) params.get("checkmoneyReceiptnumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(checkmoneyReceiptnumber), "checkmoney_receiptnumber", checkmoneyReceiptnumber);
             String orderTakeEffectTime = (String) params.get("orderTakeEffectTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderTakeEffectTime), "order_take_effect_time", orderTakeEffectTime);
          String collectionTime = (String) params.get("collectionTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(collectionTime), "collection_time", collectionTime);
             String interestRate = (String) params.get("interestRate");
         queryWrapper.eq(ToolUtil.isNotEmpty(interestRate), "interest_rate", interestRate);
             String financeManagerReview = (String) params.get("financeManagerReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(financeManagerReview), "finance_manager_review", financeManagerReview);
          String managerReview = (String) params.get("managerReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(managerReview), "manager_review", managerReview);
  		Page<bpmCrmSubstitutionEntity> page = bpmCrmSubstitutionMapper.selectPage(new Query<bpmCrmSubstitutionEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmSubstitutionEntity bpmCrmSubstitutionEntity) {
		Page<bpmCrmSubstitutionEntity> page = bpmCrmSubstitutionMapper.findPage(new Query<bpmCrmSubstitutionEntity>(params).getPage(), bpmCrmSubstitutionEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmSubstitutionByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmSubstitutionById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmSubstitution(bpmCrmSubstitutionEntity bpmCrmSubstitution){
        return save(bpmCrmSubstitution);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmSubstitutionById(bpmCrmSubstitutionEntity bpmCrmSubstitution) {
		return updateById(bpmCrmSubstitution);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmSubstitutionEntity getbpmCrmSubstitutionById(String id){
		return getById(id);
	}
}
